package importxml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class Importtests {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*VCard card = new VCard("test.vcf");
		System.out.println(card.getTitle() + " " + card.getFirstName() + " " + card.getLastName());
		System.out.println(card.getOffice() + "\n" + card.getPhoneNumber() + "\n" + card.getEmail());
		if (card.isValid()) {
			System.out.println("\n ok!!");
		}
		Icalendar ical = new Icalendar("test.ical");
		
		System.out.println(ical.getEvent(0).getStart() + "\n" + ical.getEvent(0).getWarningDate());
		System.out.println("\n" + ical.getEvent(1).getStart() + "\n" + ical.getEvent(1).getWarningDate());
		if (ical.isValid()) {
			System.out.println("ok");
		}
		XmlParser parser = new XmlParser("C:\\Documents and Settings\\slimbo86\\workspace\\dbtests");
		try {
			if (parser.parse()) {
				System.out.println("hoi");
				System.out.println(parser.getCourse(0).getTutorType(2));
			}
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		System.out.println("ok");
		File dir = new File("C:\\Documents and Settings\\slimbo86\\workspace\\dbtests\\porno");
		File file = new File("C:\\Documents and Settings\\slimbo86\\workspace\\dbtests\\hoi.txt");
		File file2 = new File("C:\\Documents and Settings\\slimbo86\\workspace\\dbtests\\hoihoi.txt");
		try {
			copyFile(file, file2);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Class clObj;

	    clObj = file.getClass();
	    System.out.println(clObj.getName());
	}
	
	static void recursiveDelete(File dirPath) {
	    String [] ls = dirPath.list ();
	    for (int idx = 0; idx < ls.length; idx++) {
	    	File file = new File (dirPath, ls [idx]);
	    	if (file.isDirectory ())
	        recursiveDelete (file);
	    	file.delete ();
	    }
	    dirPath.delete();
	}
	
	public static void copyFile(File in, File out) throws IOException {
    FileChannel inChannel = new FileInputStream(in).getChannel();
    FileChannel outChannel = new FileOutputStream(out).getChannel();
    try {
        inChannel.transferTo(0, inChannel.size(), outChannel);
    } 
    catch (IOException e) {
        throw e;
    }
    finally {
        if (inChannel != null) inChannel.close();
        if (outChannel != null) outChannel.close();
    }
}


}
